#!/bin/bash

# 项目路径
PROJECT_PATH="`pwd`"
# 项目名称
PROJECT_NAME="SulitLoan"
# Scheme 名称
SCHEME_NAME="SulitLoan"
## 输出路径
OUTPUT_PATH="${PROJECT_PATH}/build"
# 归档路径
ARCHIVE_PATH="${OUTPUT_PATH}/${PROJECT_NAME}.xcarchive"

# 清理项目
xcodebuild clean -workspace "${PROJECT_PATH}/${PROJECT_NAME}.xcworkspace" -scheme "${SCHEME_NAME}" -configuration Release

## 构建项目
#xcodebuild -workspace "${PROJECT_PATH}/${PROJECT_NAME}.xcworkspace" -scheme "${SCHEME_NAME}" -configuration Release -sdk iphoneos build
#
## 创建.ipa文件
#xcodebuild -exportArchive -archivePath ./build/"${SCHEME_NAME}".xcarchive -exportOptionsPlist ExportOptions.plist -exportPath ./build
#
## 导出ipa文件
#xcrun -sdk iphoneos PackageApplication -v ./build/"${SCHEME_NAME}".xcarchive/Products/Applications/"${SCHEME_NAME}".app -o ./build/"${SCHEME_NAME}".ipa


# 创建归档
xcodebuild archive -workspace "${PROJECT_PATH}/${PROJECT_NAME}.xcworkspace" -scheme "${SCHEME_NAME}" -archivePath "${ARCHIVE_PATH}" -configuration Release

# 导出 IPA 文件
xcodebuild -exportArchive -archivePath "${ARCHIVE_PATH}" -exportPath "${OUTPUT_PATH}" -exportOptionsPlist "${PROJECT_PATH}/ExportOptions.plist"

echo "IPA 文件已导出到: ${OUTPUT_PATH}"
#echo "IPA 文件已导出到: ${OUTPUT_PATH}"
